package com.ruyuan.rapid.core;

import com.ruyuan.rapid.core.discovery.RegistryManager;
import lombok.extern.slf4j.Slf4j;

/**
 * 核心启动类
 * 项目启动主入口
 * @author mac
 */
@Slf4j
public class Bootstrap {

    public static void main(String[] args) {
        // 1.加载网关配置信息
        RapidConfig rapidConfig = RapidConfigLoader.getInstance().load(args);

        // 2.插件初始化的工作
        // 3.注册中心初始化
        try {
            RegistryManager.getInstance().initialized(rapidConfig);
        } catch (Exception e) {
            log.error("RegistryManager is failed", e);
        }

        RapidContainer rapidContainer = new RapidContainer(rapidConfig);
        rapidContainer.start();

        Runtime.getRuntime().addShutdownHook(new Thread(rapidContainer::shutdown));
    }
}
